package patrol.mobile.com.mobilepatrol.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import patrol.mobile.com.mobilepatrol.R;


/**
 * Created by shjshi on 2017/8/15.
 */

public class AppleDialog extends Dialog {
    private String title;
    private TextView tv_title;
    private TextView tv_cancel;
    private TextView tv_sure;
    private SureListener mListener;
    public AppleDialog(Context context, int themeResId, String title) {
        super(context, themeResId);
        this.title = title;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_dialog1);
        initView();
        initTitle();
        initListener();
    }

    private void initListener() {
        tv_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AppleDialog.this.dismiss();
            }
        });
        tv_sure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mListener.onSure();
            }
        });
    }

    public void setmListener(SureListener mListener) {
        this.mListener = mListener;
    }

    private void initTitle() {
        tv_title.setText(title);
    }

    private void initView() {
        tv_title = ((TextView) findViewById(R.id.tv_title));
        tv_cancel = ((TextView) findViewById(R.id.tv_cancel));
        tv_sure = ((TextView) findViewById(R.id.tv_sure));
    }
    public interface SureListener{
        void onSure();
    }
}
